<!--
 * @Author Malred
 * @Date 2025-06-02 05:13:16
 * @Description 
 -->
<!-- Operation.vue -->
<template>
  <el-dialog v-model="visible" :title="title" width="50%">
    <el-form :model="formData" label-width="120px">
      <slot></slot>
    </el-form>
    <template #footer>
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="submit">提交</el-button>
    </template>
  </el-dialog>
</template>

<script setup>
import { ref } from 'vue';

// 定义 emits
const emit = defineEmits(['submit']);

// 控制弹窗显示
const visible = ref(false);

// 显示方法
const show = () => {
  visible.value = true;
};

// 提交方法
const submit = () => {
  emit('submit'); // 触发 submit 事件
  visible.value = false;
};

// 暴露方法给父组件调用
defineExpose({ show });

import { defineProps } from 'vue';

defineProps({
  title: String,
  formData: {
    type: Object,
    default: () => ({})
  }
});
</script>
